package sueca2011;

/**
 *
 * @author Renzo, Hugo, gabrieloliveira
 */
public class Carta {
    public static final int NIPE_ESPADAS=0;
    public static final int NIPE_COPAS=1;
    public static final int NIPE_OUROS=2;
    public static final int NIPE_PAUS=3;

    public static final int CARTA_AS=0;
    public static final int CARTA_7S=1;
    public static final int CARTA_REI=2;
    public static final int CARTA_VALETE=3;
    public static final int CARTA_DAMA=4;
    public static final int CARTA_6S=5;
    public static final int CARTA_5S=6;
    public static final int CARTA_4S=7;
    public static final int CARTA_3S=8;
    public static final int CARTA_2S=9;

    public static final String CARTA_AS_ESPADAS="spades-a-75.png";
    public static final String CARTA_7S_ESPADAS="spades-7-75.png";
    public static final String CARTA_REI_ESPADAS="spades-k-75.png";
    public static final String CARTA_VALETE_ESPADAS="spades-j-75.png";
    public static final String CARTA_DAMA_ESPADAS="spades-q-75.png";
    public static final String CARTA_6S_ESPADAS="spades-6-75.png";
    public static final String CARTA_5S_ESPADAS="spades-5-75.png";
    public static final String CARTA_4S_ESPADAS="spades-4-75.png";
    public static final String CARTA_3S_ESPADAS="spades-3-75.png";
    public static final String CARTA_2S_ESPADAS="spades-2-75.png";

    public static final String CARTA_AS_COPAS="hearts-a-75.png";
    public static final String CARTA_7S_COPAS="hearts-7-75.png";
    public static final String CARTA_REI_COPAS="hearts-k-75.png";
    public static final String CARTA_VALETE_COPAS="hearts-j-75.png";
    public static final String CARTA_DAMA_COPAS="hearts-q-75.png";
    public static final String CARTA_6S_COPAS="hearts-6-75.png";
    public static final String CARTA_5S_COPAS="hearts-5-75.png";
    public static final String CARTA_4S_COPAS="hearts-4-75.png";
    public static final String CARTA_3S_COPAS="hearts-3-75.png";
    public static final String CARTA_2S_COPAS="hearts-2-75.png";

    public static final String CARTA_AS_OUROS="diamonds-a-75.png";
    public static final String CARTA_7S_OUROS="diamonds-7-75.png";
    public static final String CARTA_REI_OUROS="diamonds-k-75.png";
    public static final String CARTA_VALETE_OUROS="diamonds-j-75.png";
    public static final String CARTA_DAMA_OUROS="diamonds-q-75.png";
    public static final String CARTA_6S_OUROS="diamonds-6-75.png";
    public static final String CARTA_5S_OUROS="diamonds-5-75.png";
    public static final String CARTA_4S_OUROS="diamonds-4-75.png";
    public static final String CARTA_3S_OUROS="diamonds-3-75.png";
    public static final String CARTA_2S_OUROS="diamonds-2-75.png";

    public static final String CARTA_AS_PAUS="clubs-a-75.png";
    public static final String CARTA_7S_PAUS="clubs-7-75.png";
    public static final String CARTA_REI_PAUS="clubs-k-75.png";
    public static final String CARTA_VALETE_PAUS="clubs-j-75.png";
    public static final String CARTA_DAMA_PAUS="clubs-q-75.png";
    public static final String CARTA_6S_PAUS="clubs-6-75.png";
    public static final String CARTA_5S_PAUS="clubs-5-75.png";
    public static final String CARTA_4S_PAUS="clubs-4-75.png";
    public static final String CARTA_3S_PAUS="clubs-3-75.png";
    public static final String CARTA_2S_PAUS="clubs-2-75.png";
    
    private int nipe;
    private int numero;
    public Carta(int nipe,int numero){
        this.nipe = nipe;
        this.numero = numero;
    }

    public int compareTo(int nipeTrunfo, int nipePuxada, Carta carta){
        if(carta.getNipe()==this.getNipe()){
            if(this.getNumero()<carta.getNumero())
                return 1;
            else
                return -1;
        }else{
            if(this.getNipe()==nipeTrunfo)return 1;
            else if(carta.getNipe()==nipeTrunfo)return -1;
            else{
                if(this.getNipe()==nipePuxada)return 1;
                else if(carta.getNipe()==nipePuxada)return -1;
            }
        }
        
        return 0;
    }

    public String toString(){
        String str="(";
        switch(this.getNipe()){
            case NIPE_COPAS:
                str+="COPAS";
                break;
            case NIPE_ESPADAS:
                str+="ESPADAS";
                break;
            case NIPE_OUROS:
                str+="OUROS";
                break;
            case NIPE_PAUS:
                str+="PAUS";
                break;
        }
        str+=",";
        switch(this.getNumero()){
            case CARTA_AS:
                str+="AS";
                break;
            case CARTA_7S:
                str+="7";
                break;
            case CARTA_REI:
                str+="REI";
                break;
            case CARTA_VALETE:
                str+="VALETE";
                break;
            case CARTA_DAMA:
                str+="DAMA";
                break;
            case CARTA_6S:
                str+="6";
                break;
            case CARTA_5S:
                str+="5";
                break;
            case CARTA_4S:
                str+="4";
                break;
            case CARTA_3S:
                str+="3";
                break;
            case CARTA_2S:
                str+="2";
                break;
        }
        str+=")";
        return str;
    }


    public int getNipe() {
        return nipe;
    }

    public String nipeToString(int nipe){
        switch(nipe){
            case NIPE_ESPADAS:
                return "ESPADAS";
            case NIPE_COPAS:
                return "COPAS";
            case NIPE_OUROS:
                return "OUROS";
            case NIPE_PAUS:
                return "PAUS";
            default:
                return "";
        }
    }


    public int getNumero() {
        return numero;
    }

    public String imageURL(){
        String str="";
        switch(this.getNipe()){
            case NIPE_COPAS:
                str+="hearts";
                break;
            case NIPE_ESPADAS:
                str+="spades";
                break;
            case NIPE_OUROS:
                str+="diamonds";
                break;
            case NIPE_PAUS:
                str+="clubs";
                break;
        }
        str+="-";
        switch(this.getNumero()){
            case CARTA_AS:
                str+="a";
                break;
            case CARTA_7S:
                str+="7";
                break;
            case CARTA_REI:
                str+="k";
                break;
            case CARTA_VALETE:
                str+="j";
                break;
            case CARTA_DAMA:
                str+="q";
                break;
            case CARTA_6S:
                str+="6";
                break;
            case CARTA_5S:
                str+="5";
                break;
            case CARTA_4S:
                str+="4";
                break;
            case CARTA_3S:
                str+="3";
                break;
            case CARTA_2S:
                str+="2";
                break;
        }
        str+="-75.png";
        return str;
    }
}
